<template>
  <div>
    <div class="demo">
      <h1>学生姓名：{{name}}</h1>
      <h1>年龄：{{age}}</h1>
      <button @click="sendStudentName">把学生名给school组件</button>
    </div>
  </div>
</template>

<script>
export default {
  name: "Student",
  data() {
    return {
      msg: 'hello',
      name: "张三",
      age: 12
    }
  },
  methods: {
    sendStudentName() {
      this.$bus.$emit('sendName', this.name)
    }
  },
  mounted() {
    console.log('student',window.x)
    console.log('student',this)
  }

}
</script>

<style scoped lang="css">
  .demo {
    background: orange;
  }
</style>